#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,l1,r1,l2,r2;
	cin>>n>>l1>>r1>>l2>>r2;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	sort(a+l1-1,a+r1);
	sort(a+l2-1,a+r2,cmp);
	cout<<a[0];
	for(int i=1;i<n;++i)
		cout<<" "<<a[i];
	return 0;
}